<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>CSS 选择器</title>
    <link rel="stylesheet" href="style.css">
</head>

<body>

    <ul>
        <li></li>
    </ul>

    <button onclick="add()">Add Once</button>
    <button onclick="del()">Del Once</button>
    <script type="text/javascript">

        var oUl = document.getElementsByTagName('ul')[0];
        var oLi = document.getElementsByTagName('li');

        del = () => {
            if(oLi.length > 1)oUl.removeChild(oLi[oLi.length - 1]);
        }
        add = () => {
            if(oLi.length < 9){
                var nLi = document.createElement('li');
                oUl.appendChild(nLi);
            }
        }

    </script>

</body>

</html>